<!-- <template>
  <!-- No changes to template section -->
</template>

<script>
import { login, getUserInfo } from '../../api/login'

export default {
  methods: {
    async handleLogin() {
      try {
        const res = await login(this.loginForm)
        if (res.code === 200) {
          // 保存token
          localStorage.setItem('token', res.token)
          
          // 获取用户认证状态
          const userInfo = await getUserInfo()
          const authStatus = this.convertAuthStatus(userInfo.isOk)
          localStorage.setItem('authenticationStatus', authStatus)
          
          // 根据认证状态处理
          if (authStatus === 'approved') {
            this.$router.push('/')
          } else if (authStatus === 'pending') {
            this.$message.warning('您的认证正在审核中，请耐心等待')
            this.$router.push('/login?message=auth_pending')
          } else if (authStatus === 'rejected') {
            this.$message.error('认证未通过，请重新提交')
            this.$router.push('/ren')
          } else {
            this.$message.info('请先完成商家认证')
            this.$router.push('/ren')
          }
        }
      } catch (error) {
        console.error('登录失败', error)
      }
    },
    
    // 转换认证状态
    convertAuthStatus(isOk) {
      switch (isOk) {
        case 0:
          return 'pending'
        case 1:
          return 'approved'
        case 2:
          return 'rejected'
        default:
          return null
      }
    }
  }
}
</script>

<style></style>
  /* No changes to style section */
</style>  -->